/**
 * <p> title �� CourseServiceImpl.java</p>
 * <p> package �� cn.edu.hit.education.service</p>
 * <p> description ��TODO</p>
 * <p> copyright �� ��������ҵ��ѧ(C) 2019</p>
 * <p> company �� ��������ҵ��ѧAS&MT</p>
 * <p> author �� ��ѩ�� jinxuesong@163.com</p>
 * <p> date �� 2021��4��21�� ����4:38:16</p>
 * <p> version �� v1.0 </p>
 *
 * Modification  History:
 * Date         Author        Version        Discription
 * -----------------------------------------------------------------------------------
 * 2021��4��21��       ��ѩ��          1.0             1.0
 * Why & What is modified: <�޸�ԭ������>
 */
package cn.edu.hit.education.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.hit.education.dao.CourseMapper;
import cn.edu.hit.education.pojo.Course;
import cn.edu.hit.education.pojo.CourseExample;
import cn.edu.hit.education.shiro.UserRealm;

@Service
public class CourseServiceImpl implements ICourseService {

	@Autowired
	CourseMapper courseMapper;
	
	@Autowired
	IUserService userService;

	@Override
	public int insert(Course course) {
		return courseMapper.insert(course);
	}

	@Override
	public int deleteByPrimaryKey(int id) {
		return courseMapper.deleteByPrimaryKey(id);
	}


	@Override
	public int update(Course course) {
		return courseMapper.updateByPrimaryKey(course);
	}


	@Override
	public List<Course> queryAllCourse() {
		CourseExample example = new CourseExample();
		CourseExample.Criteria criteria = example.createCriteria();
		criteria.andIdGreaterThan(0);

		return courseMapper.selectByExample(example);
	}


	@Override
	public List<Course> queryCoursesByPropertyId(int propertyId) {
		CourseExample example = new CourseExample();
		CourseExample.Criteria criteria = example.createCriteria();
		criteria.andPropertyIdEqualTo(propertyId);
	
		return courseMapper.selectByExample(example);
		
		
	}


	@Override
	public List<Course> queryCoursesBySpecialtyPropertyId(int specialtyId,
			int propertyId) {
		CourseExample example = new CourseExample();
		CourseExample.Criteria criteria = example.createCriteria();
		criteria.andSpecialtyIdEqualTo(specialtyId);
		criteria.andPropertyIdEqualTo(propertyId);
		return courseMapper.selectByExample(example);
	}

	@Override
	public List<Course> queryCoursesByIds(Set<Integer> ids) {
		List<Integer> list2 = new ArrayList<Integer>();
		list2.addAll(ids);

		CourseExample example = new CourseExample();
		CourseExample.Criteria criteria = example.createCriteria();
		criteria.andIdIn(list2);

		return courseMapper.selectByExample(example);
	}

	@Override
	public Course queryCourseByPrimaryKey(int id) {
		return courseMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<Course> queryAllCourseBySpecityId(List<Integer> ids) {
		CourseExample example = new CourseExample();
		CourseExample.Criteria criteria = example.createCriteria();
		criteria.andSpecialtyIdIn(ids);
		return courseMapper.selectByExample(example);
	}

}
